package com.doraro.coal.moudle.user.model.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.time.LocalDateTime;

import static com.baomidou.mybatisplus.annotation.FieldFill.INSERT;
import static com.baomidou.mybatisplus.annotation.FieldFill.INSERT_UPDATE;

/**
 * <p>
 * 系统用户
 * </p>
 *
 * @author doraro
 * @since 2019-09-26
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("sys_user")
@ApiModel(value = "User对象", description = "系统用户")
@AllArgsConstructor
@NoArgsConstructor
public class User implements Serializable {

    private static final long serialVersionUID = 1L;

    @TableId(value = "user_id", type = IdType.AUTO)
    private Long userId;

    @ApiModelProperty(value = "用户名")
    private String username;

    @ApiModelProperty(value = "密码")
    private String password;

    @ApiModelProperty(value = "盐")
    private String salt;

    @ApiModelProperty(value = "邮箱")
    private String email;

    @ApiModelProperty(value = "手机号")
    private String mobile;
    @ApiModelProperty(value = "姓名")
    private String nickName;
    @ApiModelProperty(value = "状态  0：禁用   1：正常  2:初始化")
    private Integer status;


    @ApiModelProperty(value = "角色ID")
    private Long roleId;
    @ApiModelProperty(value = "组织ID")
    private Long orgId;
    @ApiModelProperty(value = "头像url")
    private String avatarUrl;
    @ApiModelProperty(value = "创建时间")
    @TableField(fill = INSERT)
    private LocalDateTime createTime;
    @ApiModelProperty(value = "更新时间")
    @TableField(fill = INSERT_UPDATE)
    private LocalDateTime updateTime;



    public User(User user) {
        this.userId = user.userId;
        this.username = user.username;
        this.password = user.password;
        this.salt = user.salt;
        this.email = user.email;
        this.mobile = user.mobile;
        this.nickName = user.nickName;
        this.status = user.status;
        this.roleId = user.roleId;
        this.orgId = user.orgId;
        this.avatarUrl = user.avatarUrl;
        this.createTime = user.createTime;
        this.updateTime = user.updateTime;
    }
}
